package com.yingxin.yx.framework.security.exception;

import com.yingxin.yx.framework.unified.dispose.Result;
import com.yingxin.yx.framework.unified.dispose.exception.error.CommonErrorCode;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class SecurityExceptionHandler {

    /**
     * AccessDeniedException
     *
     * @param e
     * @return
     * @throws Throwable
     */

    @ExceptionHandler(AccessDeniedException.class)
    public Result handleAccessDeniedException(AccessDeniedException e) throws Throwable {
        // errorDispose(e);
        // outPutError(BusinessException.class, CommonErrorCode.NO_PERMISSION, e);
        return Result.ofFail(CommonErrorCode.NO_PERMISSION.getCode(), e.getMessage());
    }

}
